<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h5>编辑管理员</h5>
            </div>
            <div class="ibox-content">
                <a href="<?php echo e(getBackUrl()); ?>">
                    <button class="btn btn-primary btn-sm" type="button"><i class="fa fa-plus-circle"></i> 返回</button>
                </a>
                <form class="form-horizontal m-t-md" action="<?php echo e(route('admins.update',$admin->id)); ?>"
                      method="post" accept-charset="UTF-8" enctype="multipart/form-data">
                    <div class="panel-body">
                        <div class="panel-group" id="accordion">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h5 class="panel-title">
                                        <a data-toggle="collapse" data-parent="#accordion"
                                           href="tabs_panels.html#collapseOne">基础信息</a>
                                    </h5>
                                </div>
                                <div id="collapseOne" class="panel-collapse collapse in">
                                    <div class="panel-body">

                                        <input type="hidden" name="goBackUrl" value="<?php echo e(getBackUrl()); ?>"/>
                                        <?php echo csrf_field(); ?>

                                        <?php echo e(method_field('PATCH')); ?>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">用户名：</label>
                                            <div class="input-group col-sm-2">
                                                <input type="text" class="form-control" name="name"
                                                       value="<?php echo e($admin->name); ?>" required
                                                       data-msg-required="请输入用户名" autocomplete="off">
                                                <?php if($errors->has('name')): ?>
                                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i><?php echo e($errors->first('name')); ?></span>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">密码：</label>
                                            <div class="input-group col-sm-2">
                                                <input type="password" class="form-control" name="password"
                                                       data-msg-required="请输入密码" autocomplete="off">
                                                <?php if($errors->has('password')): ?>
                                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i><?php echo e($errors->first('password')); ?></span>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">头像：</label>
                                            <div class="input-group col-sm-2">
                                                <input type="file" class="form-control" name="avatr">
                                                <?php if($errors->has('avatr')): ?>
                                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i><?php echo e($errors->first('avatr')); ?></span>
                                                <?php endif; ?>
                                                <span class="view picview ">
                                                   <img id="thumbnail-avatar" class="thumbnail img-responsive"
                                                        src="<?php echo e($admin->avatr); ?>"
                                                        width="100" height="100">
                                                </span>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">游戏:&nbsp;&nbsp;
                                                <input type="checkbox" value="" onclick="checkAll(this)"></label>
                                            <div class="input-group col-sm-10">
                                                <?php echo $__env->make('widget.game', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">渠道:&nbsp;&nbsp;
                                                <input type="checkbox" value="" onclick="checkAll(this)"></label>
                                            <div class="input-group col-sm-10">
                                                <?php echo $__env->make('widget.channel_all', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                                            </div>
                                        </div>
                                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">状态：</label>
                                            <div class="input-group col-sm-1">
                                                <select class="form-control" name="status">
                                                    <option value="1"
                                                            <?php if($admin->status == 1): ?> selected="selected" <?php endif; ?>>正常
                                                    </option>
                                                    <option value="2"
                                                            <?php if($admin->status == 2): ?> selected="selected" <?php endif; ?>>锁定
                                                    </option>
                                                </select>
                                                <?php if($errors->has('status')): ?>
                                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i><?php echo e($errors->first('status')); ?></span>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a data-toggle="collapse" data-parent="#accordion"
                                           href="tabs_panels.html#collapseTwo">业务授权</a>
                                    </h4>
                                </div>
                                <div id="collapseTwo" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <div class="form-group">
                                            <table class="table table-striped table-bordered table-hover table-condensed">
                                                <?php $__currentLoopData = $datas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if(in_array($k,[1,3,48])): ?>
                                                        <?php continue; ?>
                                                    <?php endif; ?>
                                                    <?php if(empty($item->_data)): ?>
                                                        <tr class="b-group">
                                                            <th width="10%">
                                                                <label>
                                                                    &nbsp;&nbsp;<?php echo e($item->name); ?>&nbsp;
                                                                    <input type="checkbox" name="rule_id[]"
                                                                           value="<?php echo e($item->id); ?>"
                                                                           onclick="checkAllRule(this)"
                                                                           <?php if(in_array($item->id,$reqRuleId)): ?> checked="checked" <?php endif; ?>>
                                                                </label>
                                                            </th>
                                                            <td></td>
                                                        </tr>
                                                    <?php else: ?>
                                                        <tr class="b-group">
                                                            <th width="10%">
                                                                <label>
                                                                    &nbsp;&nbsp;<?php echo e($item->name); ?>&nbsp;<input
                                                                            class="module-prefix"
                                                                            type="checkbox"
                                                                            name="rule_id[]"
                                                                            value="<?php echo e($item->id); ?>"
                                                                            <?php if(in_array($item->id,$reqRuleId)): ?> checked="checked"
                                                                            <?php endif; ?>
                                                                            onclick="checkAllRule(this)">
                                                                </label>
                                                            </th>
                                                            <td class="b-child">
                                                                <?php $__currentLoopData = $item->_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <table class="table table-striped table-bordered table-hover table-condensed">
                                                                        <tr class="b-group">
                                                                            <th width="10%">
                                                                                <label>
                                                                                    <?php echo e($value->name); ?>&nbsp;<input
                                                                                            class="prefix"
                                                                                            type="checkbox"
                                                                                            name="rule_id[]"
                                                                                            value="<?php echo e($value->id); ?>"
                                                                                            <?php if(in_array($value->id,$reqRuleId)): ?> checked="checked"
                                                                                            <?php endif; ?>
                                                                                            onclick="checkAllRule(this)">
                                                                                </label>
                                                                            </th>
                                                                            <td>
                                                                                <?php if(!empty($value->_data)): ?>
                                                                                    <?php $__currentLoopData = $value->_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                        <label>
                                                                                            &emsp;<?php echo e($val->name); ?> <input
                                                                                                    type="checkbox"
                                                                                                    name="rule_id[]"
                                                                                                    value="<?php echo e($val->id); ?>"
                                                                                                    <?php if(in_array($val->id,$reqRuleId)): ?> checked="checked"
                                                                                                    <?php endif; ?>
                                                                                                    onclick="checkTh(this)">
                                                                                        </label>
                                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                                <?php endif; ?>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a data-toggle="collapse" data-parent="#accordion"
                                           href="tabs_panels.html#collapseThree">后台授权</a>
                                    </h4>
                                </div>
                                <div id="collapseThree" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <div class="form-group">
                                            <table class="table table-striped table-bordered table-hover table-condensed">
                                                <?php $__currentLoopData = $datas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if(!in_array($k,[1,3,48])): ?>
                                                        <?php continue; ?>
                                                    <?php endif; ?>
                                                    <?php if(empty($item->_data)): ?>
                                                        <tr class="b-group">
                                                            <th width="10%">
                                                                <label>
                                                                    &nbsp;&nbsp;<?php echo e($item->name); ?>&nbsp;
                                                                    <input type="checkbox" name="rule_id[]"
                                                                           value="<?php echo e($item->id); ?>"
                                                                           onclick="checkAllRule(this)"
                                                                           <?php if(in_array($item->id,$reqRuleId)): ?> checked="checked" <?php endif; ?>>
                                                                </label>
                                                            </th>
                                                            <td></td>
                                                        </tr>
                                                    <?php else: ?>
                                                        <tr class="b-group">
                                                            <th width="10%">
                                                                <label>
                                                                    &nbsp;&nbsp;<?php echo e($item->name); ?>&nbsp;<input
                                                                            class="module-prefix"
                                                                            type="checkbox"
                                                                            name="rule_id[]"
                                                                            value="<?php echo e($item->id); ?>"
                                                                            <?php if(in_array($item->id,$reqRuleId)): ?> checked="checked"
                                                                            <?php endif; ?>
                                                                            onclick="checkAllRule(this)">
                                                                </label>
                                                            </th>
                                                            <td class="b-child">
                                                                <?php $__currentLoopData = $item->_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <table class="table table-striped table-bordered table-hover table-condensed">
                                                                        <tr class="b-group">
                                                                            <th width="10%">
                                                                                <label>
                                                                                    <?php echo e($value->name); ?>&nbsp;<input
                                                                                            class="prefix"
                                                                                            type="checkbox"
                                                                                            name="rule_id[]"
                                                                                            value="<?php echo e($value->id); ?>"
                                                                                            <?php if(in_array($value->id,$reqRuleId)): ?> checked="checked"
                                                                                            <?php endif; ?>
                                                                                            onclick="checkAllRule(this)">
                                                                                </label>
                                                                            </th>
                                                                            <td>
                                                                                <?php if(!empty($value->_data)): ?>
                                                                                    <?php $__currentLoopData = $value->_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                        <label>
                                                                                            &emsp;<?php echo e($val->name); ?> <input
                                                                                                    type="checkbox"
                                                                                                    name="rule_id[]"
                                                                                                    value="<?php echo e($val->id); ?>"
                                                                                                    <?php if(in_array($val->id,$reqRuleId)): ?> checked="checked"
                                                                                                    <?php endif; ?>
                                                                                                    onclick="checkTh(this)">
                                                                                        </label>
                                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                                <?php endif; ?>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                    <div class="form-group">
                        <div class="col-sm-12 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit"><i
                                        class="fa fa-check"></i>&nbsp;保 存
                            </button>
                            　
                            <button class="btn btn-white" type="reset"><i class="fa fa-repeat"></i>
                                重 置
                            </button>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </form>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script>
        function checkAll(obj) {
            $(obj).parents('.form-group').eq(0).find("input[type='checkbox']:visible").prop('checked', obj.checked).change();
        }

        //游戏checkbox
        $('#tdGames').find(':checkbox').change(function () {
            var game_id = $(this).val();
            if (this.checked) {
                $('#tdChannels div[data-game-id="' + game_id + '"]').show().find("input:checkbox").prop('checked', true);
            } else {
                $('#tdChannels div[data-game-id="' + game_id + '"]').hide().find("input:checkbox").prop('checked', false);
            }
        });

        function checkAllRule(obj) {
            $(obj).parents('.b-group').eq(0).find("input[type='checkbox']").prop('checked', $(obj).prop('checked'));

            if (obj.checked == true) {
                $(obj).parents('.b-group').eq(1).find('.module-prefix').prop('checked', true).change();
            } else {
                if ($(obj).parents('td.b-child').find("input[type='checkbox']:checked").length == 0) {
                    $(obj).parents('tr').eq(1).find('.module-prefix').prop('checked', false);
                }
            }
        }

        function checkTh(obj) {
            if (obj.checked == true) {
                $(obj).parents('.b-group').eq(0).find('.prefix').prop('checked', true).change();
                $(obj).parents('.b-group').eq(1).find('.module-prefix').prop('checked', true).change();

            } else {
                if ($(obj).parents('td').eq(0).find("input[type='checkbox']:checked").length == 0) {
                    $(obj).parents('tr').eq(0).find('.prefix').prop('checked', false);
                }
                if ($(obj).parents('td.b-child').find("input[type='checkbox']:checked").length == 0) {
                    $(obj).parents('tr').eq(1).find('.module-prefix').prop('checked', false);
                }
            }
        }
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>